package club.justwill.single.persistence.jpo;

import club.justwill.single.persistence.support.HistoryJpo;
import club.justwill.single.persistence.support.OrderItemBase;

import javax.persistence.*;

/**
 * Created by luoyu on 15-12-24.
 */
@Entity
@Table(name = "order_item_history")
@NamedQueries({
        @NamedQuery(name = "OrderItem.searchOrderItemByOrderId",
                query = "select oi from OrderItem oi where oi.orderId = :orderId")
})
public class OrderItemHistory extends OrderItemBase implements HistoryJpo<OrderItem> {

    @Id
    @Column(name = "sequence")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long sequence;

    @Column(name = "order_id")
    private long orderId;

    @Column(name = "sku_id")
    private long skuId;

    public Long getSequence() {
        return sequence;
    }

    public void setSequence(Long sequence) {
        this.sequence = sequence;
    }

    @Override
    public void copy(OrderItem obj) {
        super.copyBase(obj);
    }

    public long getOrderId() {
        return orderId;
    }

    public void setOrderId(Long orderId) {
        if(orderId == null) {
            this.orderId = 0L;
        } else {
            this.orderId = orderId;
        }
    }

    public long getSkuId() {
        return skuId;
    }

    public void setSkuId(Long skuId) {
        if(skuId == null) {
            this.skuId = 0L;
        } else {
            this.skuId = skuId;
        }
    }
}
